import { DeviceEventEmitter } from 'react-native';

import {
  FacePositionChangeData,
  CurrentTimeChangeData,
  CoinProgressData,
  SubmitSuccessData,
  SignInSuccessData,
  ShowFaceSuccessData,
  NoFaceData,
  ImpromptuAreaProps
} from './types.d';

export const CLASS_ROOM_EVENT_FACE_POSITION_CHANGE = 'facePositionChange';
export const CLASS_ROOM_EVENT_CURRENT_TIME_CHANGE = 'currentTimeChange';
export const CLASS_ROOM_EVENT_UPDATE_COIN_PROGRESS = 'updateCoinProgress';

export const CLASS_ROOM_EVENT_SUBMIT_SUCCESS = 'submitSuccess';
export const CLASS_ROOM_EVENT_SIGN_IN_SUCCESS = 'signInSuccess';
export const CLASS_ROOM_EVENT_SHOW_FACE_SUCCESS = 'showFaceSuccess';
export const CLASS_ROOM_EVENT_UPDATE_NO_FACE = 'noFace';
export const CLASS_ROOM_EVENT_ROLL_CALL_IMPROMPTU = 'rollCallImpromptu';

export const emitFacePositionChange = (data: FacePositionChangeData): void => {
  DeviceEventEmitter.emit(CLASS_ROOM_EVENT_FACE_POSITION_CHANGE, data);
};

export const emitCurrentTimeChange = (data: CurrentTimeChangeData): void => {
  DeviceEventEmitter.emit(CLASS_ROOM_EVENT_CURRENT_TIME_CHANGE, data);
};

export const emitUpdateCoinProgress = (data: CoinProgressData): void => {
  DeviceEventEmitter.emit(CLASS_ROOM_EVENT_UPDATE_COIN_PROGRESS, data);
};

export const emitSubmitSuccess = (data: SubmitSuccessData): void => {
  DeviceEventEmitter.emit(CLASS_ROOM_EVENT_SUBMIT_SUCCESS, data);
};

export const emitSignInSuccess = (data: SignInSuccessData): void => {
  DeviceEventEmitter.emit(CLASS_ROOM_EVENT_SIGN_IN_SUCCESS, data);
};

export const emitShowFaceSuccess = (data: ShowFaceSuccessData): void => {
  DeviceEventEmitter.emit(CLASS_ROOM_EVENT_SHOW_FACE_SUCCESS, data);
};

export const emitNoFace = (data: NoFaceData): void => {
  DeviceEventEmitter.emit(CLASS_ROOM_EVENT_UPDATE_NO_FACE, data);
};

export const emitRollCallImpromptu = (data: ImpromptuAreaProps): void => {
  DeviceEventEmitter.emit(CLASS_ROOM_EVENT_ROLL_CALL_IMPROMPTU, data);
};
